import Router from 'koa-router'
import { Setting } from '../../service'
const router = new Router();

router.get('/paybase', async(ctx)=>{
    return await Setting.get('paybase')
})

router.post('/setPaybase', async(ctx)=>{
    if(ctx.request.body && ctx.request.body.value){
        return await Setting.save('paybase', ctx.request.body.value)
    }else{
        ctx.throw(401, 'bad request');
    }
})

router.get('/detail', async(ctx)=>{
    return await Setting.get('paydetail')
})

router.post('/setDetail', async(ctx)=>{
    if(ctx.request.body && ctx.request.body.value){
        return await Setting.save('paydetail', ctx.request.body.value)
    }else{
        ctx.throw(401, 'bad request');
    }
})

export default router
